import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
// ===================================================================== declare
const { $Lazy, $http } = window
// ===================================================================== Lazy
const SaoImage 	= $Lazy.load(()=>import('#tp/sao'))
const message 	= $Lazy.file(()=>import('@antd/message'))
// ===================================================================== component
const afterSuffix = <SaoImage />

class Index extends React.Component{
	state = {
		// 提交表单列表
		formData : [
			{ label: '扫码入库',				name: 'entrant_code', 		full:true, 		outer:true,		afterSuffix,	p: '请扫描或输入条码号',
				onEnter: (value) => { this.dataEntry('sp-container-item/deposit', value) }
			},
			{ label: '扫码出库',				name: 'goOut_code', 		full:true, 		outer:true,		afterSuffix,	p: '请扫描或输入条码号',
				onEnter: (value) => { this.dataEntry('sp-container-item/retrieve', value) }
			},
		]
	}
	
	uuid = ''
	submit = {
		action: 'spec_code'
	}
	
	open = param => {
		this.modal.open({ formRef: this.formRef })
		this.uuid= param.uuid
	}
	
	dataEntry = (api, spec_code) => {
		$http.submit(null, api, { param: { uuid: this.uuid, spec_code } }).then(res => {
			message.then(f=>f.success(`操作成功`))
			this.formRef.setValue({entrant_code: '', goOut_code: ''})
		})
	}
	
	render(){
		return FormModal.call(this,{ title: '出库', labelWidth:'s7', width:600, clear:true, noOk: true, onCancel: () => { this.props.onRefresh() } })
	}
}

export default Index